<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>列表</title>
<link rel="stylesheet" href="${basePath}css/styles.css" />
<link rel="stylesheet"
	href="${basePath}css/font-awesome-4.7.0/css/font-awesome.min.css" />
<script src="${basePath}js/jquery-3.6.0.js" type="text/javascript"></script>
</head>

<body>
	<form action="${basePath}wbw?method=show" method="post">
		<div class="condition">
			姓名： <input type="text" name="name" value="${wbw.name}"> 型号： <input
				type="text" name="xinghao" value="${wbw.xinghao}"> 类型： <input
				type="text" name="leixing" value="${wbw.leixing}">
			<button>
				<i class="fa fa-search"></i> 查询
			</button>
			<button onclick="window.location.href='${basePath}wbw?method=list';"
				type="button">
				<i class="fa fa-arrow-left"></i> 返回
			</button>
		</div>
	</form>
	<form action="${basePath}wbw?method=show" id="tableList" method="post">
		<input type="hidden" name="pageno" value="${pageinfo.pageno}">
		<input type="hidden" name="name" value="${wbw.name}"> <input
			type="hidden" name="xinghao" value="${wbw.xinghao}">
		<table class="tablelist">
			<thead>
				<tr>
					<th>编号</th>
					<th>型号</th>
					<th>日期</th>
					<th>姓名</th>
					<th>备注</th>
					<th>数量</th>
					<th>类型</th>
					<th>状态</th>
					<c:if test="${type == 1}">
						<th class="caozuo">操作</th>
					</c:if>
				</tr>
			</thead>
			<c:forEach items="${pageinfo.list}" var="wbw">

				<tr>
					<td>${wbw.id}</td>
					<td>${wbw.xinghao}</td>
					<td>${wbw.date}</td>
					<td>${wbw.name}</td>
					<td>${wbw.beizhu}</td>
					<td>${wbw.num}</td>
					<td>${wbw.leixing}</td>
					<td><c:if test="${wbw.zhuangtai == 1}">管理员已知</c:if> <c:if
							test="${wbw.zhuangtai == 0}">管理员未知</c:if></td>
					<c:if test="${type == 1}">
						<td>
							<button type="button"
								style="background-color: green; color: white;"
								onclick="konw('${wbw.id}')">
								<i style="background-color: green;" class="fa fa-check"></i>已知
							</button>
							<button type="button"
								style="background-color: red; color: white;"
								onclick="unkonw('${wbw.id}')">
								<i style="background-color: red;" class="fa fa-arrows-alt"></i>未知
							</button>
						</td>
					</c:if>
				</tr>
			</c:forEach>
		</table>
		<%@include file="../fenye.jsp"%>
	</form>
	<script type="text/javascript">
		function updateStatus(id, type) {

			$.post("${basePath}/updateStatus", {
				id : id,
				type : type
			}, function(data, status) {
				alert("更新成功");
				window.location.href = '${basePath}wbw?method=show'
			});

		}

		function konw(id) {
			updateStatus(id, 1)
		}
		function unkonw(id) {
			updateStatus(id, 0)
		}
	</script>
</body>

</html>
